<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch"
          data-options="{searchDatagrid:$.CurrentNavtab.find('#loanWantLoanTable')}">
        <fieldset>
            <legend style="font-weight:normal;">搜索：</legend>

            <div class="bjui-row col-2">
                <label class="row-label">真实姓名:</label>
                <div class="row-input">
                    <input type="text" name="realName" class="form-control" size="30" title="真实姓名">
                </div>

                <label class="row-label">受理状态：</label>
                <div class="row-input">
                    <input type="text" name="accepted" class="form-control" size="30" title="受理状态">
                </div>

                <label class="row-label">申请时间：</label>
                <div class="row-input">
                    <input type="text" name="dateFromTo.from" data-toggle="datepicker" data-nobtn="true" size="14">
                    -
                    <input type="text" name="dateFromTo.to" data-toggle="datepicker" data-nobtn="true" size="14">
                </div>

                <label class="row-label"></label>
                <div class="row-input">
                    <div class="btn-group">
                        <button type="submit" class="btn-green" data-icon="search">搜索</button>
                        <button type="reset" class="btn-orange" data-icon="times">重置</button>
                    </div>
                </div>

            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table id="loanWantLoanTable" class="table table-bordered">
    </table>
</div>

<script type="text/javascript" src="/js/toolDate.js"></script>
<script type="text/javascript">
    $(function () {
        var columns = [
            {
                label: "操作",
                aligh: "center",
                render: function (value, data) {
                    if (data === undefined) {
                        return '';
                    }
                    var wantLoanButton = '<button type="button" class="btn-green" onclick="accept(\'' + data.wantLoanId + '\');">受理</button>';
                    return wantLoanButton;
                }
            }, {
                label: "真实姓名",
                aligh: "center",
                name: "realName"
            }, {
                label: "手机号码",
                aligh: "center",
                name: "phone"
            }, {
                label: "借款金额",
                aligh: "center",
                name: "loanAmountD"
            }, {
                label: "借款用途",
                aligh: "center",
                name: "useOf"
            }, {
                label: "抵押物",
                aligh: "center",
                name: "pawn"
            }, {
                label: "受理备注",
                aligh: "center",
                name: "acceptNote"
            }, {
                label: "申请时间",
                aligh: "center",
                name: "addDate"
            }];

        $("#loanWantLoanTable").datagrid({
            height: '100%',
            width: '100%',
            fullGrid : true,
            showToolbar: false,
            filterThead: false,
            dataUrl: '/admin/loan/loan/ajax/wantLoan',
            local: "remote",
            inlineEditMult: false,
            delConfirm: true,
            columns: columns,
            paging: {pageSize: 20, pageIndex: 1},
            linenumberAll: true
        });

    });

    function accept(wantLoanId) {

        if (!wantLoanId) return;

        var openURL = "/admin/loan/loan/wantLoanDialog?wantLoanId=" + wantLoanId;

        BJUI.dialog({
            id: 'loanWantLoan',
            url: openURL,
            title: '受理申请贷款',
            resizeable: true,
            fresh: true,
            height: 400*0.618,
            width: 400,
            onClose: function () {
                BJUI.navtab('refresh');
            }
        });
    }
</script>